<template>
	<view>
		<web-view :src="url" calss="web"></web-view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		CONFIG
	} from '../../untils/config.js'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		userStore
	} from '../../store/userStore.js';
	let store = userStore()

	let url = ref('')

	onLoad((data) => {
		let type = data.type
		console.log(type)

		if (type == "1") {
			// https://m.amap.com/navi/?dest=116.470098,39.992838&destName=阜通西&hideRouteIcon=1&key=您申请的Key&jscode=您申请的安全密钥
			url.value =
				`https://m.amap.com/navi/?dest=${store.currentPos.longitude},${store.currentPos.latitude}&destName=我的位置&hideRouteIcon=1&key=${CONFIG.gaode_key}&jscode=${CONFIG.gaode_skey}`
			// https://m.amap.com/navi/?start=parameter1&dest=parameter2&destName=parameter3&key=parameter5&jscode=您申请的安全密钥
		} else if (type == "2") {
			let lat = data.lat
			let lon = data.lon
			url.value =
				`https://m.amap.com/navi/?start=${store.currentPos.longitude},${store.currentPos.latitude}&dest=${lat},${lon}&destName=${data.name}&key=${CONFIG.gaode_key}&jscode=${CONFIG.gaode_skey}`
				console.log(url.value)
			uni.setNavigationBarTitle({
				title: "到" + data.name + "的路径"
			})
		}
	})
	// https://m.amap.com/navi/?start=108.93537380111717,34.32750923809711&dest=34.292586,108.96353&destName=大明宫&key=f1655e2ea8ca29ddb83e045bc6cbb1b0&jscode=9c8fa6eefee191e1911104ac5a1f23da
</script>

<style>
</style>